// pages/activityLeave/activityLeave.js
import {activityLeave} from "../../services/activityReq";

Page({

    /**
     * 页面的初始数据
     */
    data: {
        titleValue: '',
        commentValue: '',
        activityId: '',
        activityleaveReason: ""
    },
    handleCommentChange(event) {
        console.log(event)
        this.setData({
            activityleaveReason: event.detail.value
        })
    },
    handleAddNow() {
        let activityId = ~~this.data.activityId;
        let activityleaveReason = this.data.activityleaveReason;

        if (!activityleaveReason) return wx.showToast({
            title: "请输入请假理由",
            icon: "error"
        });

        let params = {
            activityId,
            activityleaveReason
        }
        // console.log(params)
        wx.showLoading({
            title: "Loading....",
            mask:true,
        })
        activityLeave(params, res => {
            // console.log(res)
            if (res.data.code !== 0) return wx.showToast({
                title: res.data.msg,
                icon: "error"
            })
            return wx.showToast({
                title: "请假成功",
                icon: "success"
            })
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log(options)
        this.setData({
            activityId: options.id
        })
    },

})
